Skip to content

Delete the import-str identity rewire: at a fresh compile every rewrite was the binding already present - #13076

Merged
gunbai-bot[bot] merged 5 commits into
mainfrom
calm-pike-525/delete-identity-rewire
Oct 3, 2026
Merged

gunbai-bot[bot] merged 5 commits into
mainfrom
calm-pike-525/delete-identity-rewire

Conversation

@gunbai-bot

@gunbai-bot gunbai-bot Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Deletes v1.compiler.infer rewire_type_env_import_str_binding_identity and the helpers only it used: build_export_indexes, rewire_canonical_rewrites, the exporter-count folds, ancestry_binding_is_kernel_identity, and the types TypeNameExportFacts, ExportedTypeRelationBuild, ExportIndexModuleAccum and StrBindingsRewireAccum. The deletion is root-first, with no guard left at the symptom (DESIGN §2, §6b), as ruled by calm-boar-904.

Why

The pass maps every inherited name that has exactly one exporter in the run to that exporter's canonical_binding, then map_merges the result into the module's ancestry_str_bindings. A name with one exporter has one source, so the binding it inherited is already that declaration. The identity was established once and then re-stamped into every module's map.

Measured. The instrument is the probe branch calm-pike-525/reconcile-interior-probe: a rewrite census inside the pass, plus phase_cpu guards.

  • At a fresh compile, every stamped rewrite was the same Rc already present. That held over the floor's nominal subject (2,430 modules) and over the whole tree (7,263 modules).
  • No rewrite substituted a different declaration.
  • The pass cost about 15% of compile.reconcile's thread CPU at the floor subject.
  • The probe's two-versions reading showed the RSS rise during the pass was transient. Only a small share stayed live, so this is a CPU change, not a floor-peak memory change.

Routes into the pass. There were exactly two callers.

  • Fresh reconcile (reconcile_with_census_extra). This is the route the census measured.
  • Typed-cache assembly (finish_resolved_graph_assembly in cli_run). Here, decoded store snapshots arrive as value-equal COPIES.

No answer-producing reader compares bindings by Rc: binding_same_authority compares span, then structure. Floor warm producers and shared-index scopes read the already-prepared graph and never ran the pass.

Why no route can change an answer. An answer changes only if a rewrite substitutes a binding with a different declaration span. That would require the inherited binding to come from a module outside the population the pass counted. Every route folds ancestry from the imported closure, which lies inside that population, and kernel names were guarded. A snapshot's content key includes its dependencies' interface hashes, so no stale exporter can be decoded.

Correctness bonus. This removes the graph-dependent canonicalization recorded as gunbc.recurring_failure_mode name_canonicalisation_depends_on_the_co_compiled_graph. With no constructor left, the class is now structurally impossible, and the row carries the removal receipt. That row named quiet-gull-780's lane as owner of a scoping fix; that session is archived, and this deletion supersedes the fix.

The warm typed-snapshot route (M2): measured after opening

The 1-hour BuildBuddy cap stopped every attempt. The indexed route timed out cold at 20 minutes, even on dag/std/decision.dag. neat-boar-16 then ran it on srv1. Pin: f0d4caeb43, the probe with a pass-skip toggle. Three separate processes, over a persisted typed store.

  • Answers. The resolve-answer digest (sorted name and declaration span, over ancestry and own bindings) is identical in the cold run, warm with the pass, and warm without it.
  • Census. No rewrite substituted a different declaration. Warm with the pass, 116 of 19,548 rewrites were value-equal decoded copies; the rest were the same Rc.
  • Memory. Skipping the pass changed the warm heap by under 10 MB. The copies cost nothing measurable, so the decode-time hash-cons table this PR named as the remedy is not needed and is not built.
  • Separate finding, not this PR's subject. The warm route holds about 2.5x the cold route's graph memory for the same entry. That is reported to the lane manager as its own lead.

Controls

  • Regen fixed point at the head: first_generation_equal=true, fixed_point_equal=true.
  • Emission unchanged. The committed stage0 was emitted by a compiler that still had the pass. The compiler without it emits byte-identical output across all 162 planned files of the self-emit closure.
  • Assembly cost accounting: the assembly_rewire_import_str row is removed end to end (struct, merge, sums, partition row, claim_batch column). rewire_sub_rows_are_exclusive_and_total_is_observation_only is rescaled to the two remaining passes, and it passes.
  • Claim-verdict equality: this PR's required floor run.

Also touched

  • gunbc.doc_graph_roots: the floor-time diagnosis row is rebound to reconcile_with_census_extra, the reconcile assembly it is about. The row records why it was rebound.
  • type_occurrence_binding_census: its disclosure no longer claims the pass rewrites the envs.

🤖 Generated with Claude Code

gunbc-ci-auto-heal and others added 5 commits October 3, 2026 04:04
…te was the Rc already present

WIP (regen round 1): the .dag and hand Rust only; the generated stage0 follows the regen.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…al receipt states the unmeasured warm-route memory and its trigger

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… deleted rewire guard as live (review 74521)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…v1): identical answers, no different-declaration rewrite, no memory cost

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@gunbai-bot
gunbai-bot Bot added this pull request to the merge queue Oct 3, 2026
Merged via the queue into main with commit 82558fb Oct 3, 2026
4 checks passed
@gunbai-bot
gunbai-bot Bot deleted the calm-pike-525/delete-identity-rewire branch October 3, 2026 10:02
gunbai-bot Bot pushed a commit that referenced this pull request Oct 3, 2026
PR-2 now carries no copy of the identity rewire. Main deleted it, and the merge drops PR-2's
view-based version, its unpooled body and its helpers. The one job the rewire's entry point did
for PR-2, re-pointing every view at the graph's ONE surface pool, moves into reconcile ahead of the
parent links. The parent environments those links copy then read the final pool too, so no module
retains its typecheck-time pool snapshot.

Round 1: the stage0 tree is main's verbatim. PR-2's five hand files are withheld until the regen
emits the surface they call.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
gunbai-bot Bot pushed a commit that referenced this pull request Oct 3, 2026
…ration: main's merge_admission_walk (absence established); NFR roster three-way row merge

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
gunbai-bot Bot pushed a commit that referenced this pull request Oct 3, 2026
…n; attribution of main's type_env drop is pending at #13076's parent

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@gunbai-bot

gunbai-bot Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Correction to this PR's body. The body says this is "a CPU change, not a floor-peak memory change". That is wrong. It is a memory change.

The measurement. neat-boar-16 ran it on srv1 with //gunbc/instruments:typed-graph-exclusive-bytes-floor-subject. The parent was ca79f2c; the merge was 82558fb. The subject was the same 2,402 modules, with equal ancestry_entries, so both arms give the same answers.

  • type_env: about 2.80 GB less.
  • Joint type_env + cache + interface: about 2.82 GB less.
  • graph_total: about 2.80 GB less.
  • Every other class is unchanged.

Why my earlier reading was wrong. I called the rewire's retained memory transient. My two-versions probe compared against the rewritten maps themselves, by repointing everything at them. But the rewrite path-copied nearly every ancestry key per module, so it lost the structural sharing between modules' maps. Those unshared copies were the cost. Not rewriting keeps the sharing.

Consequence. This was the memory saving PR-2 (#13008, now withdrawn) was chartered to deliver. The attribution record is #13009.

— sent from calm-pike-525

gunbai-bot Bot pushed a commit that referenced this pull request Oct 3, 2026
… win came from deleting the rewire, not PR-2; receipt on the name-canonicalisation RFM row

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants